<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-user-add">
			<input name="deptId"  type="hidden" th:value="${deptId}"/>
			<input name="createBy"  type="hidden" th:value="${deptId}"/>
			<input name="roleIds" type="hidden" value="5" />
			<div class="form-group">
				<label class="col-sm-3 control-label ">考号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" id="id" name="id"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">班级：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="classg" id="classg">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">姓名：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="userName" id="userName">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">性别：</label>
				<div class="col-sm-8">
					<label class="radio-box"> <input type="radio" name="gender" value="0" checked /> 男 </label>
					<label class="radio-box"> <input type="radio" name="gender" value="1" /> 女 </label>
				</div>
			</div>

		</form>
	</div>
	<div th:include="include::footer"></div>
	<script th:src="@{/assets/plugins/select/select2.js}"></script>
	<script>
        $("#form-user-add").validate({
			onkeyup: false,
        	rules:{
        		id:{
        			required:true,
        			minlength: 4,
        			maxlength: 20,
        			remote: {
                        url: ctx + "sys/user/checkLoginNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	id : function() {
                                return $.common.trim($("#id").val());
                            }
                        },
                        dataFilter: function(data, type) {
                        	return data;
                        }
                    }
        		},
        		classg:{
        			required:true,
        			minlength:2
        		},
        		userName:{
        			required:true
        		}
        	},
        	messages: {
                "id": {
                    remote: "用户已经存在"
                }
            }
        });
        
        function submitHandler() {
	        if ($.validate.form()) {
	        	add();
	        }
	    }

        function add() {
        	$.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "exam/exarrange/kdaddDo",
        		data : $('#form-user-add').serialize(),
        		async : false,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        			$.operate.successCallback(data);
        		}
        	});
        }
    </script>
</body>
</html>
